﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace KduneeShaders
{
    /// <summary>
    /// Shader oświetlenia Phonga-Blinna
    /// </summary>
    public class PhongBlinnShader : GeneralShader
    {
        /// <summary>
        /// Połyskliwość - wykładnik w równaniu na specular
        /// </summary>
        public float Shininess
        {
            get { return this.Parameters["shininess"].GetValueSingle(); }
            set { this.Parameters["shininess"].SetValue(value); }
        }

        /// <summary>
        /// Tekstura specular
        /// </summary>
        public Texture2D Specular
        {
            get { return this.Parameters["specularTexture"].GetValueTexture2D(); }
            set { this.Parameters["specularTexture"].SetValue(value); }
        }

        private bool perPixel = false;
        /// <summary>
        /// Czy oświetlenie powinno być obliczane per-pixel
        /// </summary>
        public bool PerPixel
        {
            get { return perPixel; }
            set {
                perPixel = value;
                this.CurrentTechnique = this.Techniques[(perPixel==true)?1:0];
            }
        }

        /// <summary>
        /// Konstruktor shadera
        /// </summary>
        /// <param name="content">Menadżer danych</param>
        /// <param name="diffuse">Tekstura diffuse</param>
        public PhongBlinnShader(ContentManager content, Texture2D diffuse)
            : base(content.Load<Effect>(ShadersConfig.SHADERS_PATH + @"phongblinn"))
        {
            Diffuse = diffuse;
            this.CurrentTechnique = this.Techniques[0];

            Specular = content.Load<Texture2D>(ShadersConfig.SHADERS_PATH + @"Textures\white");
        }
    }
}
